<?php
class Form_Comment extends Zend_Form 
{
    protected $_comment;
    
    public function __construct($comment = null, $options = null)
    {
        if($comment!==null){
            $this->_comment = $comment;     
        }
        parent::__construct($options);
    }
    
    public function init()
    {
        $this->setName('comment');
        $this->setAction('/comment/update/');
        $username = new Zend_Form_Element_Text('username', array('label'=>'Имя: '));
        $mail = new Zend_Form_Element_Text('email', array('label'=>' Ваш email:'));
        $message  = new Zend_Form_Element_Textarea('message', array('label'=>'Сообщение','cols'=>20, 'rows'=>5));
        $post_id = new Zend_Form_Element_Hidden('post_id');
        $parent_id = new Zend_Form_Element_Hidden('parent_id');
        $submit  = new Zend_Form_Element_Submit('submit',array('label'=>'Добавить'));
        $this->addElements(array($username, $mail, $message, $post_id, $parent_id, $submit));
        
        if($this->_comment){
            $this->populate($this->_comment->getData());
        }
    }
}